#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <math.h>

//https://leetcode.cn/problems/intersection-of-two-linked-lists/

struct ListNode {
    int val;
    struct ListNode *next;
};

// 将两个链表拼接对齐
// O(m + n)
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
    if (headA == NULL || headB == NULL) {
        return NULL;
    }
    struct ListNode *pA = headA;
    struct ListNode *pB = headB;
    while (pA != pB) {
        pA = ((pA == NULL) ? headB : pA->next);
        pB = ((pB == NULL) ? headA : pB->next);
    }
    return pA;
}

int main() {

    return 0;
}